import { incomingMessageRoutine } from './routines';
const initialState = {
  incomingMessage: [],
  loading: true,
  error: null,
};

const reducer = (state = initialState, {type, payload}) => {
  
    switch (type) {
      case incomingMessageRoutine.TRIGGER:
      return {
        ...state,
        loading: true,
      };
      case incomingMessageRoutine.SUCCESS:
          console.log('get ',payload)
        return {
          ...state,
          loading: false,
          incomingMessage: payload.body,
        }
      default:
        return state;
  
    }
  }
export default reducer;
// const initialState = {
//   data: null,
//   loading: false,
//   error: null,
// };
 
// export default function reducer(state = initialState, action) {
//   switch (action.type) {
//     case fetchData.TRIGGER:
//       return {
//         ...state,
//         loading: true,
//       };
//     case fetchData.SUCCESS:
//       return {
//         ...state,
//         data: action.payload,
//       };
//     case fetchData.FAILURE:
//       return {
//         ...state,
//         error: action.payload,
//       };
//     case fetchData.FULFILL:
//       return {
//         ...state,
//         loading: false,
//       };
//     default:
//       return state;
//   }
// }

